# _*_ coding: UTF-8 _*_
# @Time     : 2021/11/3 10:43
# @Author   : yangshuaishuai
# @Site     : http://www.hzdledu.cn/
# @File     : w4s2_unittest结果验证.py
# @Software : PyCharm

from selenium import webdriver
import time
import unittest

class Test1(unittest.TestCase):
    def setUp(self) -> None:
        self.driver = webdriver.Chrome()
        self.driver.maximize_window()

    def test(self):
        self.driver.get('https://www.baidu.com/')

        text = self.driver.find_element_by_xpath('//*[@id="s-top-left"]/a[1]').text#获取新闻text
        #assertEqual(预期值，实际值)：验证预期值和实际值是否相等，不等将报错，并且将用例标记失败
        self.assertEqual('旧闻',text)

    def tearDown(self) -> None:
        self.driver.quit()